import os
import random
from typing import Counter
import xml.etree.ElementTree as ET
from global_var import getPath

from utils.utils import get_classes

if __name__ == "__main__":
    xmlfilepath = os.path.join(getPath(), 'Annotations')
    xmlfiles = os.listdir(xmlfilepath)
    fileCount = 0
    objects = []
    for fileName in xmlfiles:
        fileCount = fileCount+1
        tree = ET.ElementTree
        tree = ET.parse(os.path.join(xmlfilepath, fileName))
        root = tree.getroot()
        needwrite = False
        for obj in root.findall('object'):
            objName = obj.find('name')
            objects.append(objName.text)
    objCount = Counter(objects)
    print("data file count: ",fileCount)
    print("object count: ")
    print(objCount)